package br.ufpe.cin.camid.core.agents;

import java.util.Timer;
import java.util.TimerTask;

import com.google.inject.Singleton;

@Singleton
public class AgentConfig {

	private Timer timer;
	
	public AgentConfig()
	{
		timer = new Timer("AgentThread", true);
	}
	
	public void register(TimerTask timerTask)
	{
		long delay = 100;
		long period = 1000;
		if(timerTask.getClass().isAnnotationPresent(Agent.class))
		{
			Agent config = timerTask.getClass().getAnnotation(Agent.class);
			delay = config.delay();
			period = config.period();
		}
		timer.scheduleAtFixedRate(timerTask, delay, period);
	}
	
}
